#!/usr/bin/env bash

ROOT=~/data/YLIMED/mp4_short_encode
TrainSplit=$ROOT/YLIMED_short_mp4_EvAll_split_train.txt
TestSplit=$ROOT/YLIMED_short_mp4_EvAll_split_test.txt
PosValSplit=$ROOT/YLIMED_short_mp4_Ev101_110_split_val.txt
DEVTrainSplit=$ROOT/YLIMED_short_mp4_EvAll_split_train_dev.txt
DEVTestSplit=$ROOT/YLIMED_short_mp4_EvAll_split_test_dev.txt
TOYSplit=$ROOT/YLIMED_short_mp4_EvAll_split_test_toy.txt

# echo $0
NAME=select_2_seg5
LOG=./out/$NAME/log
MODEL=./out/$NAME/weights
TEST_OUT=./out/$NAME/scores_seg5_crop1
source activate coviar
######################################################
# train
######################################################
# CUDA_VISIBLE_DEVICES=1,2,3 \
# python train.py --arch resnet152 --data-name ylimed \
#     --data-root  $ROOT \
#     --train-list $TrainSplit \
#     --test-list  $PosValSplit \
#     --representation iframe \
#     --model-prefix $MODEL/ylimed \
#     --lr      0.0003 \
#     --lstm_lr 0.00003 \
#     --hidden_size 1024 \
#     --batch-size 25 \
#     --lr-steps 40 80 \
#     --epochs 90 \
#     --num_segments 5 \
#     > $LOG/ylimed_iframe_model.out 2>&1 &
# TODO

# CUDA_VISIBLE_DEVICES=1,2,3 \
# python train.py --arch resnet101 --data-name ylimed \
#     --data-root  $ROOT \
#     --train-list $TrainSplit \
#     --test-list  $PosValSplit \
#     --representation mv \
#     --model-prefix $MODEL/ylimed \
#     --lr      0.005 \
#     --lstm_lr 0.0005 \
#     --hidden_size 256 \
#     --batch-size 45 \
#     --lr-steps 80 120 \
#     --epochs 160 \
#     --num_segments 5 \
#     > $LOG/ylimed_mv_model.out 2>&1 &
# wait
# TODO 重新跑
# CUDA_VISIBLE_DEVICES=0,1,3 \
# python train.py --arch resnet101 --data-name ylimed \
#     --data-root  $ROOT \
#     --train-list $TrainSplit \
#     --test-list  $PosValSplit \
#     --representation residual \
#     --model-prefix $MODEL/ylimed \
#     --lr      0.001 \
#     --lstm_lr 0.001 \
#     --hidden_size 512 \
#     --batch-size 45 \
#     --lr-steps 80 110 \
#     --epochs 130 \
#     --num_segments 5 \
#     > $LOG/ylimed_residual_model.out 2>&1 &
# wait

######################################################
# test
######################################################
CUDA_VISIBLE_DEVICES=0,1,2,3 \
python test.py \
    --gpus 0 \
    --test_segments 5 \
    --batch-size 90 \
    --test-crops 1 \
    --arch resnet152 --data-name ylimed --representation iframe \
    --data-root $ROOT \
    --test-list $TestSplit \
    --hidden_size 1024 \
    --weights $MODEL/ylimed_iframe_model_best.pth.tar \
    --save-scores $TEST_OUT/ylimed_best_iframe_model__scores \
    > $TEST_OUT/ylimed_best_iframe_model__scores.out 2>&1 &

CUDA_VISIBLE_DEVICES=0,1,2,3 \
python test.py \
    --gpus 1 \
    --test_segments 5 \
    --batch-size 90 \
    --test-crops 1 \
    --arch resnet101 --data-name ylimed --representation mv \
    --data-root $ROOT \
    --test-list $TestSplit \
    --hidden_size 256 \
    --weights $MODEL/ylimed_mv_model_best.pth.tar \
    --save-scores $TEST_OUT/ylimed_best_mv_model__scores \
    > $TEST_OUT/ylimed_best_mv_model__scores.out 2>&1 &

CUDA_VISIBLE_DEVICES=0,1,2,3 \
python test.py \
    --gpus 2 \
    --test_segments 5 \
    --batch-size 90 \
    --test-crops 1 \
    --arch resnet101 --data-name ylimed --representation residual \
    --data-root $ROOT \
    --test-list $TestSplit \
    --hidden_size 512 \
    --weights $MODEL/ylimed_residual_model_best.pth.tar \
    --save-scores $TEST_OUT/ylimed_best_residual_model__scores \
    > $TEST_OUT/ylimed_best_residual_model__scores.out 2>&1 &
